/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.veles.infowindow;

import cz.muni.fi.veles.MapServer;
import cz.muni.fi.veles.MapUtils;
import cz.muni.fi.veles.maps.AbstractMap;
import javax.faces.component.UIComponentBase;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;

/**
 * Information window component
 * @author Jan Ferko
 */
@JsfComponent(
        family=AbstractInfoWindow.COMPONENT_FAMILY,
        type=AbstractInfoWindow.COMPONENT_TYPE,
        renderer=@JsfRenderer(family=AbstractInfoWindow.COMPONENT_FAMILY, 
        type="cz.muni.fi.veles.InfoWindowRenderer")
)
public abstract class AbstractInfoWindow extends UIComponentBase{
   public static final String COMPONENT_FAMILY = "cz.muni.fi.veles";
   public static final String COMPONENT_TYPE = "cz.muni.fi.veles.InfoWindow";
   
   /**
    * Default value: {@code false}
    * @return indicator if info window is shown
    */
   @Attribute(defaultValue="false", generate=true)
   public abstract boolean isShown();
   
   /**
    * 
    * @return maximum width of info window
    */
   @Attribute(defaultValue="200")
   public abstract int getMaxWidth();
   
   /**
    * 
    * @return number of offset pixels
    */
   @Attribute(defaultValue="0")
   public abstract int getOffsetPixels();
   
   
   /**
    * 
    * @return latitude of info window
    */
   @Attribute
   public abstract Double getLatitude();
   
   /**
    * 
    * @return longitude of info window
    */
   @Attribute
   public abstract Double getLongitude();
   /**
    * Resolves parent map server
    * @return parent map server
    */
   public MapServer resolveMapServer(){
        return this.getParentMap().getMapServer();
    }

   /**
    * 
    * @return parent map of info window
    */
    public AbstractMap getParentMap(){
        return MapUtils.getParentMap(this);
    }
}
